package com.itboye.mengwu.data.repository;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.google.gson.reflect.TypeToken;
import com.itboye.core.interfaces.ICompleteListener;
import com.itboye.core.utils.BaseErrorListener;
import com.itboye.core.utils.BaseSuccessReqListener;
import com.itboye.core.utils.ByJsonRequest.Builder;
import com.itboye.mengwu.data.interfaces.IAppHeadPage;
import com.itboye.mengwu.data.interfaces.ILunBo;
import com.itboye.mengwu.data.model.AppHeadPage;
import com.itboye.mengwu.data.model.HomePageModel;
import com.itboye.mengwu.data.model.LunBoModel;

public class HomePageResitory extends BaseNetRepository implements IAppHeadPage {
	public static final String Banner = "BY_App_viewPage";
	public static final String Query = "BY_App_queryPage";
	public static final String LunBo = "BY_File_banner";

	String api = "100";

	public HomePageResitory(ICompleteListener listener) {
		// TODO Auto-generated constructor stub
		super(listener);
	}

	@Override
	public void add(AppHeadPage model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void delete(AppHeadPage model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void update(AppHeadPage model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void getInfo(AppHeadPage model) {
		// TODO Auto-generated method stub
		String apiVer = api;
		Type type = new TypeToken<AppHeadPage>() {
		}.getType();
		Map<String, Object> map = new HashMap<String, Object>();
		(new Builder<AppHeadPage>())
				.setTypeVerParamsAndReturnClass(Query, apiVer, map, type)
				.requestListener(
						new BaseSuccessReqListener<AppHeadPage>(getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();
	}

	@Override
	public List<AppHeadPage> query(AppHeadPage model) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void appHead(String pageId) {
		// TODO Auto-generated method stub
		String apiVer = api;
		Type type = new TypeToken<AppHeadPage>() {
		}.getType();
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("page_id", pageId);
		(new Builder<AppHeadPage>())
				.setTypeVerParamsAndReturnClass(Banner, apiVer, map, type)
				.requestListener(
						new BaseSuccessReqListener<AppHeadPage>(getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();
	}

	@Override
	public void lunbo(int posion) {
		// TODO Auto-generated method stub
		String apiVer = api;
		Type type = new TypeToken<ArrayList<LunBoModel>>() {
		}.getType();
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("position", posion);
		(new Builder<ArrayList<LunBoModel>>())
				.setTypeVerParamsAndReturnClass(LunBo, apiVer, map, type)
				.requestListener(
						new BaseSuccessReqListener<ArrayList<LunBoModel>>(getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();
	}
}
